<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
namespace app\common\model;

use think\Model;

class Moulds extends Model
{
    public function category()
    {
        return self::hasOne('Category','id','c_id')->field('category');
    }
    public static function getMouldList()
    {
        $list = self::paginate(20);

        $attributes=AttrValue::getAttrValue();
        foreach ($list as $k=>$v){
            if(!empty($v['attribute'])){
                $attribute=explode('|',$v['attribute']);
                foreach ($attribute as $key=>$val){
                    $attribute[$key]=$attributes[$val];
                }
                $v['attribute']=implode('|',$attribute);
            }
        }
        return $list;
    }
    public static function getMouldInfo($id)
    {
        $list = self::where('id',$id)->find();
        return $list;
    }


}